const router = require('express').Router()
const {db,pool}=require('../db/db')
const goodsSQL=require('../db/goodsSQL')
const fs = require('fs')
const { getList: MGT, getGoodsById: MGBI ,info:MI} = require('../middleware/goods')
const { getList: CGT, getGoodsById: CGBI, category: CC ,campuls:CCA,info:CI} = require('../controller/goods')

router.get('/list', MGT, CGT)
router.get('/item/:id', MGBI, CGBI)
router.get('/item', MGBI, CGBI)
router.get('/category', CC)
router.get('/campuls', CCA)
router.get('/admin_info',MI, CI)
router.post('/admin_update',(req,res,next)=>{
  pool.query(goodsSQL.updateGoods,[req.body.campuls,req.body.category,req.body.quality,req.body.price,req.body.email,req.body.phone,req.body.title,req.body.goodsId],(err,result)=>{undefined
    if(err) throw err;
    console.log(result);
  });
  res.send({code:2})
})
module.exports = router
